﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Function2Role.aspx.cs" Inherits="Manage_WebPages_UserInfo_Function2Role" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="../../js/jquery.js" type="text/javascript"></script>
    <script src="../../js/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
    <link href="../../js/bootstrap/css/style.css" rel="stylesheet" type="text/css"/>
    <link href="../../js/bootstrap/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
    <script src="../../js/Common.js" type="text/javascript"></script>
    <script type="text/javascript" language="javascript">
        function OnTreeNodeChecked() {
            var ele = event.srcElement; //获取数据源
            if (ele.type == 'checkbox') {
                var childrenDivID = ele.id.replace('CheckBox', 'Nodes');
                var div = document.getElementById(childrenDivID);
                if (div == null) {
                } else {
                    var checkBoxs = div.getElementsByTagName('INPUT');
                    for (var i = 0; i < checkBoxs.length; i++) {
                        if (checkBoxs[i].type == 'checkbox')
                            checkBoxs[i].checked = ele.checked;
                    }
                }
                var parentDiv = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement;
                var parentParentDiv = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
                var parentParentParentDiv = event.srcElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement.parentElement;
                if (parentDiv != null && parentDiv != undefined) {
                    var parentCheckBoxID = parentDiv.id.replace('Nodes', 'CheckBox');
                    var checkBoxs = parentDiv.getElementsByTagName('INPUT');
                    var childNodeChecked = false;
                    for (var i = 0; i < checkBoxs.length; i++) {
                        if (checkBoxs[i].type == 'checkbox' && checkBoxs[i].checked)
                            childNodeChecked = true;
                    }
                    if (document.getElementById(parentCheckBoxID) != null) {
                        document.getElementById(parentCheckBoxID).checked = childNodeChecked;
                    }
                }
                if (parentParentDiv != null && parentParentDiv != undefined) {
                    var parentParentCheckBoxID = parentParentDiv.id.replace('Nodes', 'CheckBox');
                    var checkBoxs = parentParentDiv.getElementsByTagName('INPUT');
                    var childNodeChecked = false;
                    for (var i = 0; i < checkBoxs.length; i++) {
                        if (checkBoxs[i].type == 'checkbox' && checkBoxs[i].checked)
                            childNodeChecked = true;
                    }

                    if (document.getElementById(parentParentCheckBoxID) != null) {
                        document.getElementById(parentParentCheckBoxID).checked = childNodeChecked;
                    }
                }

                if (parentParentParentDiv != null && parentParentParentDiv != undefined) {
                    var parentParentParentCheckBoxID = parentParentParentDiv.id.replace('Nodes', 'CheckBox');
                    var checkBoxs = parentParentParentDiv.getElementsByTagName('INPUT');
                    var childNodeChecked = false;
                    for (var i = 0; i < checkBoxs.length; i++) {
                        if (checkBoxs[i].type == 'checkbox' && checkBoxs[i].checked)
                            childNodeChecked = true;
                    }

                    if (document.getElementById(parentParentParentCheckBoxID) != null) {
                        document.getElementById(parentParentParentCheckBoxID).checked = childNodeChecked;
                    }
                }
            }
        }
    </script>
</head>
<body>
<div class="box span12" style="width: 550px;">
    <div class="box-content">
        <form id="Form1" class="form-horizontal" runat="server">
            <asp:ScriptManager ID="ScriptManager1" runat="server">
            </asp:ScriptManager>
            <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <ContentTemplate>
                    <div class="control-group">
                        <div class="controls">
                            <asp:Button ID="btnSave" runat="server" Text="确定" OnClick="btnSave_Click" CssClass="btn btn-primary"/>
                            &nbsp;&nbsp;&nbsp;&nbsp;
                            <button type="button" class="btn" onclick="javascript:window.close();">取消</button>
                        </div>
                    </div>
                    <asp:TreeView ID="tvMenu" runat="server"
                                  onclick="OnTreeNodeChecked()">
                        <SelectedNodeStyle BackColor="#E5EFF3" CssClass="tree_text_bold"/>
                    </asp:TreeView>
                </ContentTemplate>
            </asp:UpdatePanel>
        </form>
    </div>
</div>
</body>
</html>